package com.lagou.service.impl;

import com.lagou.service.HelloService;
import org.apache.dubbo.config.annotation.Service;



@Service
public class HelloServiceImpl implements HelloService {

    @Override
    public String sayHello(String name) {
        return "hello"+name;
    }


    //--------------------homework--------------------
    //方法一
    @Override
    public String methodA() {
        sleep();
        return "methodA";
    }

    //方法二
    @Override
    public String methodB() {
        sleep();
        return "methodB";
    }

    //方法三
    @Override
    public String methodC() {
        sleep();
        return "methodC";
    }


    /**
     * 实现随机休眠0-100ms
     */
    private void sleep() {
        int Time = (int) (Math.random()*100);
        try {
            Thread.sleep(Time);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
